-
-
Notifications
You must be signed in to change notification settings - Fork 830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix AnimatePresence won't unmount fastly changing content #1569
Conversation
f435b02
to
245dafb
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Hey thanks for taking a look at this! However I think this approach replaces the bug with another - fastly outgoing elements unmount instantly, rather than waiting for their animation to finish. |
4229490
to
27c2997
Compare
@mattgperry I fixed it again for that problem. Can I review it again? |
@JaeSeoKim thanks for taking another look at this. Are these sandboxes updates with the latest fixes? |
@mattgperry I updated the sandbox samples. I would like to contribute after hearing feedback on additional problems or improvements, but I think it will be difficult to contribute additionally as I will join the army from the 27th due to the military service obligation of the Republic of Korea. |
@mattgperry Now, I can work after work. Is there anything that needs to be updated or improved?( |
8ff751d
to
4348966
Compare
@JaeSeoKim Thank you for this fix! |
@JaeSeoKim Why did you close this pull request? |
@mattgperry |
@utileetdulce I don't have enough time to work because of my mandatory military service in South Korea. and two fixes are included in one PR and i couldn't write the test codes, so i closed it with the intention of uploading it again later. A problem with commit 29c4a5b occurs when you wrap PresenceChild for the exiting component. Because |
Hey there, I was actually having the same issue with AnimatePresence not removing elements properly when multiple elements were removed in a short amount of time. However, I was able to fix the issue by using the usePresence hook from the Framer Motion documentation. The usePresence hook provides a way to animate elements that are entering and exiting a component. It works by keeping track of the presence of the element using a boolean value, and then triggering an animation when the element enters or exits the component. By using usePresence in conjunction with AnimatePresence, I was able to ensure that elements were properly removed even when multiple elements were removed in a short amount of time. I highly recommend checking out the Framer Motion documentation on usePresence for more information and examples: https://www.framer.com/motion/animate-presence/#usepresence Hope this helps! |
Description
exiting
object is not enclosed foruseRef()
as shown belowBecause the object
exiting
is a new object each time it is re-rendered, theonExit
event validates theDefer re-rendering untill all exiting child have indented left
incorrectly.2022-06-11 update
A bug occurred because the
onExit
function is newly defined each time when a fastly outgoing elements unmount instantly.To solve this problem, solved it by memoizing
exitingChild
.But when I solved this problem, I saw a different problem.
The rendering array will have a strange change position.
Generally, if a change is made from
["A", "D", "E", "F", "B", "C"]
to["1", "A", "2", "B", "3", "C"]
during animation,it is expected to be
["1" ,"A" ,"D" ,"E" ,"F" ,"2" ,"B" ,"3" ,"C"]
It does not work as intended and is output in the form
["1", "D", "E", "F", "A", "2", "B", "3", "C"]
.If a change occurs in the rendering array, insert the chunk where the change occurred in the previous location.
Demo
original
2022-06-11.1.52.25.mov
fixed:
2022-06-11.1.36.41.mov
original
2022-06-11.1.54.32.mov
fixed:
2022-06-11.1.37.11.mov
[BUG] AnimatePresence won't unmount fastly changing content #907
original: https://codesandbox.io/s/animatepresence-quick-key-change-bug-zggbr?file=/src/HoverText.js
fixed: https://codesandbox.io/s/animatepresence-quick-key-change-bug-forked-od8snl?file=/package.json
[BUG]
AnimatePresence
not keeping up #1439original: https://codesandbox.io/s/serene-poincare-q45cs?file=/src/Loader.js
fixed: https://codesandbox.io/s/silly-burnell-6ocfg4?file=/package.json
AnimatePresence doesn't catch up with multiple deletes in a row #1534
original: https://codesandbox.io/s/adoring-rubin-hsxcfh?file=/src/App.ts
fixed: https://codesandbox.io/s/young-snowflake-5z3cem?file=/package.json
fixed: #907
fixed: #1439
fixed: #1534